package com.ebc.eservice.controller.pc;

import com.ebc.eservice.service.EbcCardService;
import com.ebc.eservice.util.JsonResult;
import com.ebc.eservice.util.common.constant.ApiTextHelperConstant;
import com.ebc.eservice.util.common.constant.DeveloperConstant;
import com.ebc.eservice.vo.card.staff.CardInfoReqVo;
import com.ebc.eservice.vo.card.staff.UpdateStaffInfoReqVo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: Joey
 * @Description:名片&员工管理
 * @date:2022/9/18 0:25
 */
@Api(tags = "后台管理系统-人员-员工管理")
@RestController
@RequestMapping("/staffManage")
public class CardStaffController {

    @Autowired
    private EbcCardService ebcCardService;


    @ApiOperation(value = "添加员工 -  首页获取公司id再选择部门", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/addStaff")
    public JsonResult addStaff(@RequestBody CardInfoReqVo cardInfoReqVo){
       return ebcCardService.addPeronCard(cardInfoReqVo);
    }

    @ApiOperation(value = "获取员工列表 -", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/getStaffList")
    public JsonResult getStaffList(Integer companyId){
        int current =1 ;
        int size = 100;
        return ebcCardService.getStaffList(current,size,companyId);
    }

    @ApiOperation(value = "编辑员工信息 -姓名电话在账户管理中修改", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/modifyStaffInfo")
    public JsonResult modifyStaffInfo(@RequestBody UpdateStaffInfoReqVo updateStaffInfoReqVo){
        return ebcCardService.updateStaffInfo(updateStaffInfoReqVo);
    }

    @ApiOperation(value = "删除员工信息", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/deleteStaff")
    public JsonResult deleteStaff(Integer cardId){
        return ebcCardService.deleteStaff(cardId);
    }


    //导出excel
    @ApiOperation(value = "导出员工信息-Excel", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/exportStaffExcel")
    public void exportStaffExcel(HttpServletResponse response, Integer companyId) throws IllegalAccessException, IOException, InstantiationException {
         ebcCardService.exportStaffExcel(response,companyId);
    }



}
